from manim import *

'''
This Scene illustrates the quirks of .animate. 
When using .animate, Manim actually takes a Mobject’s starting state and its ending state 
and interpolates the two. 
In the AnimatedSquareToCircle class, you can observe this when the square rotates: 
the corners of the square appear to contract slightly as they move into the positions 
required for the first square to transform into the second one.

In DifferentRotations, the difference between .animate’s interpretation of rotation and 
the Rotate method is far more apparent. 
The starting and ending states of a Mobject rotated 180 degrees are the same, 
so .animate tries to interpolate two identical objects and the result is the left square.
 If you find that your own usage of .animate is causing similar unwanted behavior, 
consider using conventional animation methods like the right square, which uses Rotate.
'''
class AnimateSquareToCircle(Scene):
    def construct(self):
        circle = Circle()
        square = Square()

        self.play(Create(mobject=square))
        self.play(square.animate.rotate(angle=PI/4))
        self.play(Transform(mobject=square, target_mobject=circle))
        self.play(square.animate.set_fill(color=PINK, opacity=0.5))
